home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C++ / Frameworks / Sprocket Framework DR2 / Sprocket Nothing / SprocketNothing Code / EmptyWindow.cp < prev    next >
Encoding:
Text File  |  1996-06-15  |  3.0 KB  |  152 lines  |  [TEXT/CWIE]

  1. /*
  2.  
  3.     File:        EmptyWindow.cp
  4.     Project:    Sample code for Sprocket Framework 1.1 (DR2), released 6/15/96
  5.     Contains:    A window which does nothing at all, for you to build upon
  6.     To Do:        Look at Window.h to see the other functionality you can override
  7.  
  8.  
  9.     Sprocket Major Contributors:
  10.     ----------------------------
  11.     Dave Falkenburg, producer of Sprocket 1.0
  12.     Bill Hayden,     producer of Sprocket 1.1
  13.     Steve Sisak,     producer of the upcoming Sprocket 2.0
  14.     
  15.     Pete Alexander        Steve Falkenburg    Randy Thelen
  16.     Eric Berdahl        Nitin Ganatra        Chris K. Thomas
  17.     Marshall Clow        Dave Hershey        Leonard Rosenthal
  18.     Tim Craycroft        Dave Mark            Dean Yu
  19.     David denBoer        Gary Powell
  20.     Cameron Esfahani    Jon Summers            Apple Computer, Inc.
  21.         
  22.     Comments, Additions, or Corrections:
  23.     ------------------------------------
  24.     Bill Hayden, Nikol Software <nikol@codewell.com>
  25.  
  26. */
  27.  
  28.  
  29.  
  30. #include "EmptyWindow.h"
  31. #include "SprocketConstants.h"
  32.  
  33.  
  34. extern TMenuBar*    gMenuBar;    // you will need this when you start adjusting menus
  35.                                 // based on what's going on with your window
  36.  
  37.  
  38. //    methods
  39.  
  40. TEmptyWindow::TEmptyWindow()
  41. {
  42.     this->CreateWindow();    // kNormalWindow is default. Method inherited from TWindow
  43.                             // TWindow::CreateWindow() calls our MakeNewWindow().
  44. }
  45.  
  46.  
  47.  
  48. /**********************************************************************************/
  49.  
  50.  
  51.  
  52. TEmptyWindow::~TEmptyWindow()
  53. {
  54.     //    No particular cleanup in this version, since our real purpose was
  55.     //    just to demonstrate Sprocket.
  56.     
  57.     gMenuBar->EnableCommand( cClose, false );    // in case we are the only window open
  58. }
  59.  
  60.  
  61.  
  62. /**********************************************************************************/
  63.  
  64.  
  65.  
  66. WindowRef TEmptyWindow::MakeNewWindow( WindowRef behindWindow )
  67. {
  68.     WindowRef    aWindow;
  69.     GrafPtr        savedPort;
  70.     
  71.     GetPort(&savedPort);
  72.     
  73.     aWindow = GetNewColorOrBlackAndWhiteWindow( 1000, nil, behindWindow );
  74.     
  75.     if (aWindow)
  76.         {
  77.         SetPortWindowPort(aWindow);
  78.  
  79.         ShowWindow(aWindow);
  80.         }
  81.         
  82.     SetPort(savedPort);
  83.  
  84.     return aWindow;
  85. }
  86.  
  87.  
  88.  
  89. /**********************************************************************************/
  90.  
  91.  
  92.  
  93. void TEmptyWindow::Draw(void)
  94. {
  95.     // Draw your window contents here.
  96.     
  97.     
  98.     // This window is resizable, so draw the resize box
  99.     
  100.     EraseRect(&this->fWindow->portRect);
  101.     DrawJustTheGrowIcon(this->fWindow);
  102. }
  103.  
  104.  
  105.  
  106. /**********************************************************************************/
  107.  
  108.  
  109.  
  110. void TEmptyWindow::Activate( Boolean activating )
  111. {
  112.     #pragma unused(activating)
  113.     // Handle a window activate here.
  114. }
  115.  
  116.  
  117.  
  118. /**********************************************************************************/
  119.  
  120.  
  121.  
  122.  
  123. void TEmptyWindow::AdjustMenusBeforeMenuSelection(void)
  124. {
  125.     // Setup your menus before the user sees them, using calls such as this:
  126.     
  127.     gMenuBar->EnableCommand( cClose, true );    // users need to be able to close us
  128. }
  129.  
  130.  
  131.  
  132.  
  133. /**********************************************************************************/
  134.  
  135.  
  136.  
  137.  
  138. Boolean TEmptyWindow::DoCommand(CommandID theCommand)
  139. {
  140.     switch(theCommand)
  141.         {
  142.         // Handle your commands here via case statements.
  143.         
  144.         default:
  145.             return TWindow::DoCommand(theCommand);
  146.             break;
  147.         }
  148.         
  149.     return true;
  150. }
  151.         
  152.